#ifndef VSANIMTREE_H
#define VSANIMTREE_H
#include "VSController.h"
#include "VSAnimSet.h"
namespace VSEngine2
{
	class VSAnimFunction;
	class VSAnimMainFunction;
	class VSAnimBaseFunction;
	class VSSkelectonMeshNode;
	class VSStream;
	class VSGRAPHIC_API VSAnimTree : public VSController
	{
		//RTTI
		DECLARE_RTTI;
		//PRIORITY
		
	public:
		virtual ~VSAnimTree();
		virtual bool UpdateEx(double dAppTime);
	
		VSAnimTree(VSSkelectonMeshNode * pSkelectonMesh);
	protected:
		VSAnimTree();
	protected:
		VSArray<VSAnimBaseFunction *> m_pAnimFunctionArray;

		VSAnimMainFunction*  m_pAnimMainFunction;
	public:

		const VSSkelectonMeshNode * GetSkelectonMeshNode()const;


		void AddAnimFunction(VSAnimBaseFunction * pAnimFunction);
		void DeleteAnimFunction(VSAnimBaseFunction * pAnimFunction);
		inline VSAnimMainFunction * GetAnimMainFunction()const
		{
			return m_pAnimMainFunction;
		}
		virtual bool SetObject(VSObject * pObject);
		void ResetAnimFunction();

		VSAnimBaseFunction *  GetAnimFunctionFromShowName(const VSUsedName & ShowName);
	public:
		static bool RegisterMainFactory();
		virtual unsigned int DiskUse()const;

		virtual bool Save(VSStream & rStream,unsigned int &iSaveUse)const;
		virtual bool Load(VSStream & rStream,unsigned int &iSaveUse);
		virtual bool Link(VSStream & rStream);

		virtual bool Register(VSStream & rStream)const;
	private:
		static bool InitialClassFactory();	
		static VSObject * FactoryFunc();
		static bool ms_bRegisterMainFactory;
	public:
		virtual bool Clone(const VSObject *pObject,unsigned int uiType);

	};
	typedef VSPointer<VSAnimTree> VSAnimTreePtr;

	class VSGRAPHIC_API VSAnimTreeOneAnim : public VSAnimTree
	{
	public:
		VSAnimTreeOneAnim(VSSkelectonMeshNode * pSkelectionMesh,const VSString &AnimName);
		~VSAnimTreeOneAnim();
	};
	typedef VSPointer<VSAnimTreeOneAnim> VSAnimTreeOneAnimPtr;

	class VSGRAPHIC_API VSAnimTreeOnlyIK : public VSAnimTree
	{
	public:
		VSAnimTreeOnlyIK(VSSkelectonMeshNode * pSkelectionMesh,const VSString &IKRootBoneName);
		~VSAnimTreeOnlyIK();
	};
	typedef VSPointer<VSAnimTreeOnlyIK> VSAnimTreeOnlyIKPtr;

	class VSGRAPHIC_API VSAnimTreeTwoBlendAnim : public VSAnimTree
	{
	public:
		VSAnimTreeTwoBlendAnim(VSSkelectonMeshNode * pSkelectionMesh,const VSString &AnimName1,const VSString &AnimName2);
		~VSAnimTreeTwoBlendAnim();
	};
	typedef VSPointer<VSAnimTreeTwoBlendAnim> VSAnimTreeTwoBlendAnimPtr;


	class VSGRAPHIC_API VSAnimTreeRectBlendAnim : public VSAnimTree
	{
	public:
		VSAnimTreeRectBlendAnim(VSSkelectonMeshNode * pSkelectionMesh,
							const VSString &AnimName1,
							const VSString &AnimName2,
							const VSString &AnimName3,
							const VSString &AnimName4);
		~VSAnimTreeRectBlendAnim();
	};
	typedef VSPointer<VSAnimTreeRectBlendAnim> VSAnimTreeRectBlendAnimPtr;
}
#endif